package com.yonyou.rabbitmq.receiver;

import com.rabbitmq.client.Channel;
import com.yonyou.rabbitmq.common.MessageConstants;
import com.yonyou.rabbitmq.common.enums.SiteEnum;
import com.yonyou.rabbitmq.service.BaseConsumerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class WorkerReceiver5 extends BaseConsumerService {

    @RabbitListeners(value = {
            @RabbitListener(containerFactory = MessageConstants.GF_CONTAINER_FACTORY,queues = "#{rabbitConfig.queueNames(rabbitConfig.queues)}"),
            @RabbitListener(containerFactory = MessageConstants.ZW_CONTAINER_FACTORY, queues = "#{rabbitConfig.queueNames(rabbitConfig.queues)}")
    })
    @RabbitHandler
    public void onMessage(Channel channel, Message message) throws Exception {
        super.process(channel,message);
    }

    @Override
    public void doBusiness(Message message, String tenantId) {
        final String messageId = message.getMessageProperties().getMessageId();
        System.out.println(messageId);
        System.out.println(tenantId + "站点实际业务处理");
    }
}

